Raised This Month: $51 Target: $400
 12% 

[ANY] Source Fuck (A brainfuck VM)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Plugin ID:
5042
Plugin Version:
1.0.0.0
Plugin Category:
Technical/Development
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    A brainfuck virtual machine for sourcemod plugins
    Old 02-18-2016 , 13:10   [ANY] Source Fuck (A brainfuck VM)
    Reply With Quote #1

    <Source Fuck>




    Introdution

    This is a plugin for Sourcemod which provides a configurable and controllable
    virtual machine that runs brainfuck.



    Requirements

    this plugin needs the things listed below to work:
    • nothing without SM and MM



    Installation

    to install this plugin
    • put the smx file in the sourcemod/plugins folder
    to compile this plugin manually
    • put all sp files in the sourcemod/scripting folder
    • put all inc files in the sourcemod/scripting/include folder
    • compile.



    Configuration

    this plugin has nothing to config



    Example

    To use this plugin, you need to make another plugin that uses native functions of this plugin. those are

    native ArrayList SF_CreateVirtualMachine(const char[] name, int codememsize, int datamemsize, int inputmemsize, int outputmemsize);
    native ArrayList SF_FindVirtualMachine(const char[] name);
    native int SF_DeleteVirtualMachine(ArrayList vm);
    native void SF_SetVirtualMachineInstruction(ArrayList vm, const char[] token, SF_INSTRUCTION inst);
    native ArrayList SF_GetVirtualMachineInstruction(ArrayList vm, SF_INSTRUCTION inst);
    native void SF_SetVirtualMachineProperty(ArrayList vm, SF_PROPERTY prop, int value);
    native any SF_GetVirtualMachineProperty(ArrayList vm, SF_PROPERTY prop);
    native void SF_SetVirtualMachineMemory(ArrayList vm, SF_MEMORY memtype, const char[] buffer, int maxlength);
    native void SF_GetVirtualMachineMemory(ArrayList vm, SF_MEMORY memtype, char[] buffer, int maxlength);
    native SF_STATUS SF_ExecuteMachine(ArrayList vm, int maxinstcount);
    native void SF_ResetVirtualMachine(ArrayList vm);

    and there is an example test plugin code for this, which will print Hello World!\n 5 in server console when map starts.
    Code:
    #include <sourcemod>
    
    #include <sourcefuck/sourcefuck>
    
    #pragma newdecls required
    
    #define PLUGIN_VERSION "1.0.0.0"
    
    public Plugin myinfo = {
        
        name = "SourceFuckTest",
        author = "javalia",
        description = "SourceFuck virtual machine",
        version = PLUGIN_VERSION,
        url = "http://www.sourcemod.net/"
        
    };
    
    public void OnPluginStart(){
        
        CreateConVar("sourcefucktest_version", PLUGIN_VERSION, "plugin version", FCVAR_DONTRECORD);
        
    }
    
    public void OnMapStart(){
        
        ArrayList vm = SF_CreateVirtualMachine("Nyaruko", 1024, 1024, 1024, 1024);
        
        SF_SetVirtualMachineInstruction(vm, "Woo!Nya!", SF_INST_BP_INC);
        SF_SetVirtualMachineInstruction(vm, "Woo~Nya~", SF_INST_BP_DEC);
        SF_SetVirtualMachineInstruction(vm, "Woo!Nya~", SF_INST_BP_DRF_INC);
        SF_SetVirtualMachineInstruction(vm, "Woo~Nya!", SF_INST_BP_DRF_DEC);
        SF_SetVirtualMachineInstruction(vm, "Let`s Nya!", SF_INST_BP_DRF_PRINT);
        SF_SetVirtualMachineInstruction(vm, "Sanchi pinch!", SF_INST_BP_DRF_INPUT);
        SF_SetVirtualMachineInstruction(vm, "Chaos! Chaos!", SF_INST_LOOPSTART);
        SF_SetVirtualMachineInstruction(vm, "I Want a Chaos!", SF_INST_LOOPEND);
        SF_SetVirtualMachineInstruction(vm, "\n", SF_INST_WHITESPACE);//newline
        SF_SetVirtualMachineInstruction(vm, " ", SF_INST_WHITESPACE);//this is whitespace
        SF_SetVirtualMachineInstruction(vm, "    ", SF_INST_WHITESPACE);//this is tab
        
        //... is pawn`s internal multiple line string connector
        char codemem[1024] = "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Chaos! Chaos! Woo!Nya! Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya!" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya! Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya!" ...
            "Woo!Nya~ Woo~Nya~ Woo~Nya~ Woo~Nya~ Woo~Nya~" ...
            "Woo~Nya! I Want a Chaos! Woo!Nya! Woo!Nya~ Woo!Nya~" ...
            "Let`s Nya! Woo!Nya! Woo!Nya~ Let`s Nya! Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Let`s Nya! Let`s Nya! Woo!Nya~ Woo!Nya~ Woo!Nya~ Let`s Nya!" ...
            "Woo!Nya! Woo!Nya~ Woo!Nya~ Let`s Nya! Woo~Nya~ Woo~Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~ Woo!Nya~" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Let`s Nya! Woo!Nya! Let`s Nya!" ...
            "Woo!Nya~ Woo!Nya~ Woo!Nya~ Let`s Nya! Woo~Nya! Woo~Nya!" ...
            "Woo~Nya! Woo~Nya! Woo~Nya! Woo~Nya! Let`s Nya! Woo~Nya!" ...
            "Woo~Nya! Woo~Nya! Woo~Nya! Woo~Nya! Woo~Nya! Woo~Nya!" ...
            "Woo~Nya! Let`s Nya! Woo!Nya! Woo!Nya~ Let`s Nya! Woo!Nya! Let`s Nya!";
        char outputmem[1024];
        SF_SetVirtualMachineMemory(vm, SF_MEMORY_CODE, codemem, 1024);
        SF_STATUS status =  SF_ExecuteMachine(vm, -1);
        SF_GetVirtualMachineMemory(vm, SF_MEMORY_OUTPUT, outputmem, 1024);
        PrintToServer("%s %d", outputmem, status);
        
    }
    
    public void OnMapEnd(){
        
        ArrayList vm = SF_FindVirtualMachine("Nyaruko");
        if(vm != null){
            
            PrintToServer("calling delete virtual machine");
            SF_DeleteVirtualMachine(vm);
            
        }
        
        return;
        
    }
    if you dont have any idea about this sample code, you can watch this and this.



    Known Bugs & Limits of the plugin

    Limits
    • this brainfuck vm has no infinite memory. but however, u can allocate big memory if u want.
    • maximum length of a token should be shorter then 256, for there is a bug in SM(compiler or SM iself or something else. but i tested this enough and i dont think its my code`s bug).
    • i didn`t tested every functions of this plugin but only essensial ones. so there could be a bug.



    Special Thanks To

    i want to say thanks to these guys
    • dvander, for making 1.7 syntax for everyone.
    • other guys who talked with me and answered to me about my questions in the irc channel.



    Change Log

    All the date`s format is y/m/d
    Code:
    update at 2016 02 19(ver 1.0.0.0) 
    • released
    Attached Files
    File Type: zip sourcefuck(1.0.0.0).zip (22.4 KB, 282 views)
    __________________

    Last edited by javalia; 02-18-2016 at 13:55. Reason: adding missing informations
    javalia is offline
     



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 19:05.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode