HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Bank (sc2) like possible in wc3 proof included

10-13-2010, 04:49 AM#1
DioD
This system was developed by me and narayan (dont know his acc name on wc3c) nearly year ago, kept in secret for some reasons but no one used it for years cos some issues.

Well:

Collapse JASS:
// AUTHOR: narayan & diod
library DATA

  // SETUP'S DATA MANAGER
  globals
    string  SAVE_PATH      = "DataManager\\" // FILE PATH (Can be [C:\\TEMP\\EWIX])
    string  SAVE_TYPE      = ".txt"          // FILE TYPE (Can be [all posible types])
  endglobals

  // CODE PART

  globals
    private integer SyncInt   = 0
    private real    SyncFlt   = 0
    private player  SyncPlr   = null
    private string  SyncStr   = null
    private boolean SyncBool  = false

    private gamecache SyncCache = InitGameCache("SyncCache")
    private string array STR
    private string       PID    = null // for optimization
  endglobals

  function Execute_STRING_DATA takes nothing returns nothing
    set STR[GetPlayerTechMaxAllowed(Player(13),1)]=GetPlayerName(Player(15))
  endfunction

  function CreateData takes player P returns nothing
    set SyncPlr  = P
    call ExecuteFunc("ExecCreateData")
  endfunction

  function ExecCreateData takes nothing returns nothing
    if GetLocalPlayer()==SyncPlr then
      if SyncBool then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"THIS |cffff0000DATA|r ALREADY USED!")
        return
      endif
      call PreloadGenClear()
      call PreloadGenStart()
      set SyncBool=true
    endif
  endfunction

  function AddInteger takes integer Offset,integer Value,player P returns nothing
    if GetLocalPlayer()==P then
      if not SyncBool then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Data not allocated for this player")
        return
      elseif Offset<0 then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Incorrect offset on Add Integer function")
        return
      endif
      if Value>0 then
        call Preload("\")\ncall SetPlayerTechMaxAllowed(Player(15),"+I2S(Offset)+","+I2S(Value)+")\ncall SetPlayerTechMaxAllowed(Player(14),"+I2S(Offset)+",3)//")
      elseif Value<0 then
        call Preload("\")\ncall SetPlayerTechMaxAllowed(Player(15),"+I2S(Offset)+","+I2S(-Value)+")\ncall SetPlayerTechMaxAllowed(Player(14),"+I2S(Offset)+",2)//")
      endif
    endif
  endfunction

  function AddReal takes integer Offset,real Value,player P returns nothing
    if GetLocalPlayer()==P then
      if not SyncBool then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Data not allocated for this player")
        return
      elseif Offset<0 then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Incorrect offset on Add Real function")
        return
      endif
      if Value>0 then
        call Preload("\")\ncall DefineStartLocation(11,"+R2SW(Value,2,2)+","+R2S(Offset)+")//")
      else
        call Preload("\")\ncall DefineStartLocation(11,"+R2SW(Value,2,2)+","+R2S(-Offset)+")//")
      endif
    endif
  endfunction

  function AddString takes integer Offset,string S,player P returns nothing
    if GetLocalPlayer()==P then
      if not SyncBool then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Data not allocated for this player")
        return
      elseif Offset<0 or Offset>8190 then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Incorrect offset on Add String function")
        return
      endif
      call Preload("\")\ncall SetPlayerName(Player(15),\""+S+"\")\ncall SetPlayerTechMaxAllowed(Player(13),1,"+I2S(Offset)+")\ncall ExecuteFunc(\"Execute_STRING_DATA\")\n//")
    endif
  endfunction

  function AddBoolean takes integer Offset,boolean B,player P returns nothing
    if GetLocalPlayer()==P then
      if not SyncBool then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Data not allocated for this player")
        return
      elseif Offset<0 then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Incorrect offset on Add Boolean function")
        return
      endif
      if B then
        call Preload("\")\ncall SetGameTypeSupported(ConvertGameType("+I2S(Offset)+"),true)//")
      else
        call Preload("\")\ncall SetGameTypeSupported(ConvertGameType("+I2S(Offset)+"),false)//")
      endif
    endif
  endfunction

  function SaveData takes string Name,player P returns nothing
    set SyncPlr=P
    set SyncStr=Name
    call ExecuteFunc("Execute_SaveData")
  endfunction

  function Execute_SaveData takes nothing returns nothing
    if GetLocalPlayer()==SyncPlr then
      if not SyncBool then
        debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"|cffff0000Error|r: Data not allocated for this player")
        return
      endif
      set SyncBool=false
      call Preload("\")\nendfunction\nfunction recyclebin takes nothing returns nothing//")
      call PreloadGenEnd(SAVE_PATH+SyncStr+SAVE_TYPE)
    endif
  endfunction

  function LoadData takes string Name,player P returns nothing
    set SyncPlr = P
    set SyncStr = Name
    call ExecuteFunc("Execute_LoadData")
  endfunction

  function Execute_LoadData takes nothing returns nothing
    if GetLocalPlayer()==SyncPlr then
      call Preloader(SAVE_PATH+SyncStr+SAVE_TYPE)
    endif
  endfunction

  function ReadInteger takes integer Offset,player P returns integer
    set SyncInt = Offset
    set SyncPlr = P
    set PID = I2S(GetPlayerId(P))
    call ExecuteFunc("Execute_ReadInteger")
    return GetStoredInteger(SyncCache,I2S(SyncInt),PID)
  endfunction

  function Execute_ReadInteger takes nothing returns nothing
    if GetLocalPlayer()==SyncPlr then
      if GetPlayerTechMaxAllowed(Player(14),SyncInt)==2 then
        set SyncInt = -GetPlayerTechMaxAllowed(Player(15),SyncInt)
      elseif GetPlayerTechMaxAllowed(Player(14),SyncInt)==3 then
        set SyncInt = GetPlayerTechMaxAllowed(Player(15),SyncInt)
      else
        set SyncInt = 0
      endif
      call StoreInteger(SyncCache,I2S(SyncInt),PID,SyncInt)
    endif
    call TriggerSyncStart()
    if GetLocalPlayer()==SyncPlr then
        call SyncStoredInteger(SyncCache,I2S(SyncInt),PID)
    endif
    call TriggerSyncReady()
    set SyncInt = GetStoredInteger(SyncCache,I2S(SyncInt),PID)
  endfunction

  function ReadReal takes integer Offset,player P returns real
    set SyncInt = Offset
    set SyncFlt = R2I(Offset)
    set SyncPlr = P
    set PID = I2S(GetPlayerId(P))
    call ExecuteFunc("Execute_ReadReal")
    return GetStoredReal(SyncCache,I2S(SyncInt),PID)
  endfunction

  function Execute_ReadReal takes nothing returns nothing
    if GetLocalPlayer()==SyncPlr then
      if RAbsBJ(GetStartLocationY(GetPlayerStartLocation(Player(11))))!=SyncFlt then
        return
      endif
      if GetStartLocationY(GetPlayerStartLocation(Player(11)))<0 then
        set SyncFlt = -GetStartLocationX(GetPlayerStartLocation(Player(11)))
      else
        set SyncFlt = GetStartLocationX(GetPlayerStartLocation(Player(11)))
      endif
      call StoreReal(SyncCache,I2S(SyncInt),PID,SyncFlt)
    endif
    call TriggerSyncStart()
    if GetLocalPlayer()==SyncPlr then
        call SyncStoredReal(SyncCache,I2S(SyncInt),PID)
    endif
    call TriggerSyncReady()
    set SyncFlt = GetStoredReal(SyncCache,I2S(SyncInt),PID)
  endfunction

  function ReadString takes integer Offset,player P returns string
    set SyncInt = Offset
    set SyncPlr = P
    set PID = I2S(GetPlayerId(P))
    call ExecuteFunc("Execute_ReadString")
    return GetStoredString(SyncCache,I2S(SyncInt),PID)
  endfunction

  function Execute_ReadString takes nothing returns nothing
    if GetLocalPlayer()==SyncPlr then
      call StoreString(SyncCache,I2S(SyncInt),PID,STR[SyncInt])
    endif
    call TriggerSyncStart()
    if GetLocalPlayer()==SyncPlr then
        call SyncStoredString(SyncCache,I2S(SyncInt),PID)
    endif
    call TriggerSyncReady()
    set SyncStr = GetStoredString(SyncCache,I2S(SyncInt),PID)
  endfunction

  function ReadBoolean takes integer Offset,player P returns boolean
    set SyncInt = Offset
    set SyncPlr = P
    set PID = I2S(GetPlayerId(P))
    call ExecuteFunc("Execute_ReadBoolean")
    return GetStoredBoolean(SyncCache,I2S(SyncInt),PID)
  endfunction

  function Execute_ReadBoolean takes nothing returns nothing
    local boolean b=false
    if GetLocalPlayer()==SyncPlr then
      call StoreBoolean(SyncCache,I2S(SyncInt),PID,IsGameTypeSupported(ConvertGameType(SyncInt)))
    endif
    call TriggerSyncStart()
    if GetLocalPlayer()==SyncPlr then
        call SyncStoredBoolean(SyncCache,I2S(SyncInt),PID)
    endif
    call TriggerSyncReady()
    set b=GetStoredBoolean(SyncCache,I2S(SyncInt),PID)
  endfunction

endlibrary

Collapse JASS:
// Пример от Diod
scope template initializer init

 globals
   boolean load_stat = false
 endglobals

 private function Do_Load takes nothing returns nothing
   if load_stat then
     call DisplayTimedTextToForce( GetPlayersAll(),999999, "Stat's load on current moment.")
     return
   endif
   set load_stat = true
   call LoadData("test",GetTriggerPlayer())
   call BJDebugMsg("VALUE = " + I2S(ReadInteger(0x0F,GetTriggerPlayer())))
   call BJDebugMsg("BRUTE = " + I2S(ReadInteger(0x0E,GetTriggerPlayer())))
   call BJDebugMsg("Real Value = " + R2S(ReadReal(0x005,GetTriggerPlayer())))
   call BJDebugMsg("Str Value = " + ReadString(0x0,GetTriggerPlayer()))
   set load_stat = false
 endfunction

 private function Do_Save takes nothing returns nothing
   local string DATA = GetEventPlayerChatString()
   if I2S(S2I(DATA)) != DATA then
     return //invalid input
   endif
   call CreateData(GetTriggerPlayer())
   call AddInteger(0x0F,S2I(DATA),GetTriggerPlayer())
   call AddInteger(0x0E,0x00FF,GetTriggerPlayer())
   call AddReal(0x005,1200,GetTriggerPlayer())
   call AddString(0x00,"template string",GetTriggerPlayer())
   call SaveData("test",GetTriggerPlayer())
   if GetLocalPlayer()==GetTriggerPlayer() then
     call BJDebugMsg(DATA + " stored as local data, check it at warcraft dir")
   endif
 endfunction

 private function init takes nothing returns nothing
    local trigger Save = CreateTrigger()
    local trigger Load = CreateTrigger()
    local integer I = 0
// not need part
    call DisplayTimedTextToForce( GetPlayersAll(),999999, "Type integer to save it locally")
    call DisplayTimedTextToForce( GetPlayersAll(),999999, "Press ESC to load and sync saved data")
    call DisplayTimedTextToForce( GetPlayersAll(),999999, "You can enter negative value")
    call DisplayTimedTextToForce( GetPlayersAll(),999999, "")
    call DisplayTimedTextToForce( GetPlayersAll(),999999, "Enter '-save' for save hero")
    call DisplayTimedTextToForce( GetPlayersAll(),999999, "Enter '-load' for load hero")
// end part
    loop
        call TriggerRegisterPlayerChatEvent(Save, Player(I),  "", false )
        call TriggerRegisterPlayerEvent    (Load, Player(I), EVENT_PLAYER_END_CINEMATIC)
        set I = I + 1
        exitwhen I == 12
    
    endloop
    call TriggerAddAction( Save, function Do_Save )
    call TriggerAddAction( Load, function Do_Load )
  endfunction

endscope

This code will create file on users hdd locally (it can overwrite files and can be stored inside system folders, path cannot be encrypted but you may hide it well)

If needed local data from file will be uploaded to other players (sync subsystem)

It tested well and working ONLY if your map do not run any triggersleepaction (there is no direct evidence but it fail to sync any data if triggersleep is running)
Attached Files
File type: w3xdata manager v1.6.w3x (21.6 KB)
10-13-2010, 09:04 AM#2
Fledermaus
Copied the code into a blank map, typed 100. It said it had stored it, checked the .txt and yup, it was all there. (Although in the default notepad, it shows it all on one line. Notepad ++ had new lines though, so I don't think that's it)

Pressed escape to load:
VALUE = 0
BRUTE = 0
Real Value = 0.000
Str Value =

???

EDIT: Same thing with the test map you provided.
10-13-2010, 10:03 AM#3
DioD
you need local files enabled for warcraft, if local files disabled warcraft not able to load data.

this is main issue and limit for system, since there is no way to enable local files from map after code execution is fixed.
10-13-2010, 10:08 AM#4
DioD
reg file to enable local files
Attached Files
File type: zip123.zip (288 bytes)
10-13-2010, 11:59 PM#5
Fledermaus
Well that's a shame =/ I'll probably still be using it for creating load codes for people but that's not nearly as cool as I first hoped. Still pretty neat though.
10-28-2010, 03:30 PM#6
IReportBugs
Doesn't look like this will last long. But why not run the reg for them?

Writing files is writing files, unfortunately.
10-28-2010, 03:51 PM#7
Krysho
Downloaded your map to see if I could get it to desync and also to see if your string syncing worked.

Turns out I did not really need to try on the first part, it always desynced the other computer on my LAN (both with escape loading and hero loading with "-load"). Loads fine on the source computer, though.
10-28-2010, 06:11 PM#8
DioD
IReportBugs
it was not posted by me for reason, but now it dos not matter.

Krysho

ESC loading tested by me and it works fine. (changing local file with notepad and sync, other players notify about values they got)

hero loading tested by narayan, i have no info about it, looks like it symply need more time.
10-28-2010, 11:37 PM#9
Krysho
It does not seem to be working for me. The main reason I even brought it up is because I tested the sync natives quite a bit a few years ago, and walked away with the belief that TriggerSyncStart() and TriggerSyncReady() are wholly insufficient to guarantee a sync landed (I could easily force desyncs when using those natives).

In all honesty, I have no idea why those natives even exist, since it is not necessary to use "SyncStart" to send a sync, and "SyncReady" does not guarantee the sync finished. Although I am pretty sure the packets sent by the sync requests must be returned eventually (otherwise the player would desync for not responding to it), which means "SyncReady" simply was allowing the usage of values not yet synced when I used it.

I agree with your comment that the second sync needs more time. I also feel that way about the first.
10-29-2010, 01:58 AM#10
DioD
you may add timer wait like 10 seconds or more of complete code inactive, it will surely sync for this time.
12-06-2010, 07:59 PM#11
Strilanc
There's no way Blizzard will allow this to continue working. The malicious uses are obvious.

In any case, can you explain how the system works?
12-07-2010, 12:56 PM#12
Bribe
Quote:
Originally Posted by Strilanc
There's no way Blizzard will allow this to continue working. The malicious uses are obvious.

http://www.thehelper.net/forums/showthread.php?t=158371

One month running, no response from Blizzard.
12-07-2010, 01:14 PM#13
Strilanc
Quote:
Originally Posted by Bribe
http://www.thehelper.net/forums/showthread.php?t=158371

One month running, no response from Blizzard.

How long did they take on i2c? Or the weak map checksum?
12-11-2010, 10:28 PM#14
Anitarf
Well, there is the matter of informing blizzard about it. If no one comes to them with this information, we can't assume they'll find it themselves.
12-12-2010, 03:37 PM#15
Strilanc
I just assumed blizzard keeps tabs on the mapping community or has employees who are also mappers.