Buchempfehlung
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Umfassend, aber leicht verständlich führt dieses Buch in die Programmierung von ATMEL AVR Mikrocontrollern ein. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

GuildList

Uploader:MitgliedEternal_Pain
Datum/Zeit:25.07.2010 09:53:58

' http://lastchaos.aeriagames.com/community/rankings/active/Azura-EU '
    Type GuildCalcList
        GuildName     as ZString ptr
            regGuild  as Integer
        GuildALevel   as UInteger
            Player    as UInteger
            AvLevel   as UInteger
    End Type

Sub QSortS (byref xyz as GuildCalcList PTR, byval lo as UInteger, Byval hi as UInteger)

    Dim l as UInteger = lo
    Dim r as UInteger = hi
    Dim p as UByte    = xyz[(lo+hi)/2].AvLevel

        Do

            While xyz[l].AvLevel < p : l+=1 : Wend

            While xyz[r].AvLevel > p : r-=1 : Wend

            If l<=r Then
                Swap xyz[l],xyz[r]
                l+=1 : r-=1
            End If

        Loop while l<r

    If lo<r Then QSortS(xyz,lo,r)
    If l<hi Then QSortS(xyz,l,hi)

End Sub

#Include "SDL-Main.bas"

    Type ClassList
        Guild as ZString ptr
        Level as UInteger
    End Type


    Function HTMLClass2List (byval HTMLString as String) as ClassList ptr
        Dim as UInteger InfSS, InfSE, Hold
        Dim RList as ClassList ptr=Callocate(Len(ClassList)*50)
        Dim Guild as String
        Dim as UInteger Holder2
        Hold=1

        For l as integer=0 to 49

        '1. Rank
        InfSS=INSTR(Hold,HTMLString,"<td")
        InfSE=INSTR(InfSS,HTMLString,"/td>")
        Hold=InfSE+4

        '2. Name
        InfSS=INSTR(Hold,HTMLString,"<td")
        InfSE=INSTR(InfSS,HTMLString,"/td>")
        Hold=InfSE+4

        '3. Level
        InfSS=INSTR(Hold,HTMLString,"<td")
        InfSE=INSTR(InfSS,HTMLString,"/td>")
        Hold=InfSE+4

        Holder2=INSTR(InfSS,HTMLString,">")+1

        '?Mid(HTMLString,Holder2,(InfSE-Holder2)-1)
        RList[l].Level=Val(Mid(HTMLString,Holder2,(InfSE-Holder2)-1))

        '4. Guild
        Guild=""

        InfSS=INSTR(Hold,HTMLString,"<td")
        InfSE=INSTR(InfSS,HTMLString,"/td>")
        Hold=InfSE+4

        Holder2=INSTR(InfSS,HTMLString,">")+1

        Guild=Trim(Mid(HTMLString,Holder2,(InfSE-Holder2)-1))

        RList[l].Guild=Callocate(Len(Guild)+1)
        *RList[l].Guild=Guild

        '?RList[l].Level,*RList[l].Guild


        Next l

        Return RList
    End Function







   Function CreateGuildList as GuildCalcList ptr


   Dim socket As TCPsocket
'------------------------------------------------'
    ''Verbindung herstellen
    socket = TCP_open ("lastchaos.aeriagames.com")


    ''Anfrage schicken
    TCP_http ("GET",socket,"lastchaos.aeriagames.com", _
    "community/rankings/active/Azura-EU")

    '------------------------------------------------'
    ''Anfrage ergebniss einlesen

    Dim recvbuffer As Zstring * 100001
    Dim LC as String=""
    Dim bytes As Integer
    do
        bytes = SDLNet_TCP_Recv( socket, Strptr( recvbuffer ), 100000 )
        if bytes<1 then exit do

        LC+=recvbuffer

        if len(LC)>99999 Then exit Do
    loop

    '------------------------------------------------'

    ''Server/Verbindungsdaten ausschneiden
    Dim SS As Integer
    SS=Instr(Lcase(LC),"connection: close")
    'If SS=0 Then Return ""
    SS+=17

    Dim buffer as String
    buffer=Trim(Mid(LC,SS,1+(Len(LC)-SS)))

    '
    '<div class="tab-content" id="rankings">  <div class="tab-panel tab-show" id="'
    '<!-- end content -->'

    
    
    Dim relBuffer as String
    Dim rBS as UInteger
    Dim rBE as UInteger
    rBS=INSTR(  1,buffer,"<div class="+chr(34)+"tab-content"+chr(34)+" id="+chr(34)+"rankings")

    rBE=INSTR(rBS,buffer,"<!-- end content -->")
    relBuffer=Mid(buffer,rBS,rBE-rBS)
    
    'Class-Split
    Dim as UInteger ClassF,SP1,SP2
    
    'Titan
    Dim Titan as String
    
    ClassF=INSTR(relBuffer,"
titan")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"knight")
    SP2=INSTRrev(relBuffer,"
<",ClassF)
    
    Titan=Mid(relBuffer,SP1,SP2-SP1)
    
    'Knight
    Dim Knight as String
    
    ClassF=INSTR(relBuffer,"
knight")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"healer")
    SP2=INSTRrev(relBuffer,"
<",ClassF)

    Knight=Mid(relBuffer,SP1,SP2-SP1)
    
    'Healer
    Dim Healer as String
    
    ClassF=INSTR(relBuffer,"
healer")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"mage")
    SP2=INSTRrev(relBuffer,"
<",ClassF)

    Healer=Mid(relBuffer,SP1,SP2-SP1)
    
    'Mage
    Dim Mage as String
    
    ClassF=INSTR(relBuffer,"
mage")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"rogue")
    SP2=INSTRrev(relBuffer,"
<",ClassF)

    Mage=Mid(relBuffer,SP1,SP2-SP1)

    'Rogue
    Dim Rogue as String
    
    ClassF=INSTR(relBuffer,"
rogue")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"sorcerer")
    SP2=INSTRrev(relBuffer,"
<",ClassF)

    Rogue=Mid(relBuffer,SP1,SP2-SP1)
    
    'Sorcerer
    Dim Sorcerer as String
    
    ClassF=INSTR(relBuffer,"
sorcerer")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"nightshadow")
    SP2=INSTRrev(relBuffer,"
<",ClassF)

    Sorcerer=Mid(relBuffer,SP1,SP2-SP1)
    
    'Nightshadow
    Dim Nightshadow as String
    
    ClassF=INSTR(relBuffer,"
nightshadow")
    SP1=INSTR(ClassF,relBuffer,">")+1
    ClassF=INSTR(relBuffer,"<!-- end content -->")
    SP2=INSTRrev(relBuffer,"
<",ClassF)

    Nightshadow=Mid(relBuffer,SP1,SP2-SP1)

    ' <td | /td>
    relBuffer=""
    Buffer=""

    Dim GuildList       as GuildCalcList ptr
    GuildList=Callocate(Len(GuildCalcList)*100)

    Dim TitanList       as ClassList ptr
    Dim KnightList      as ClassList ptr
    Dim MageList        as ClassList ptr
    Dim HealerList      as ClassList ptr
    Dim SorcererList    as ClassList ptr
    Dim NightShadowList as ClassList ptr
    Dim RogueList       as ClassList ptr

    TitanList=HTMLClass2List (Titan)
    KnightList=HTMLClass2List (Knight)
    MageList=HTMLClass2List (Mage)
    HealerList=HTMLClass2List (Healer)
    SorcererList=HTMLClass2List (Sorcerer)
    NightShadowList=HTMLClass2List (Nightshadow)
    RogueList=HTMLClass2List (Rogue)

    Dim GuildFound as Integer

    For l as Integer=0 to 49

        If *TitanList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*TitanList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*TitanList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*TitanList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=TitanList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=TitanList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

        If *KnightList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*KnightList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*KnightList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*KnightList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=KnightList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=KnightList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

        If *MageList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*MageList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*MageList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*MageList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=MageList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=MageList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

        If *RogueList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*RogueList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*RogueList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*RogueList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=RogueList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=RogueList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

        If *HealerList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*HealerList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*HealerList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*HealerList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=HealerList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=HealerList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

        If *SorcererList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*SorcererList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*SorcererList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*SorcererList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=SorcererList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=SorcererList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

        If *NightShadowList[l].Guild<>"" Then
            GuildFound=0
            for ll as integer=0 to GuildList[0].regGuild

                If GuildList[ll].GuildName andalso *GuildList[ll].GuildName=*NightShadowList[l].Guild Then GuildFound=(ll+1):Exit for

            next ll

            If GuildFound=0 Then
                GuildList[GuildList[0].regGuild].GuildName=Callocate(Len(*NightShadowList[l].Guild)+1)
                *GuildList[GuildList[0].regGuild].GuildName=*NightShadowList[l].Guild

                GuildList[GuildList[0].regGuild].GuildALevel+=NightShadowList[l].Level
                GuildList[GuildList[0].regGuild].Player+=1

                GuildList[0].regGuild+=1
            Else
                GuildList[GuildFound-1].GuildALevel+=NightShadowList[l].Level
                GuildList[GuildFound-1].Player+=1
            End If
        End If

    Next l

    For l as Integer=0 to GuildList[0].regGuild
        GuildList[l].AvLevel=int(GuildList[l].GuildALevel/GuildList[l].Player)
    next l

    Return GuildList
End Function



Dim Test as GuildCalcList ptr
test=CreateGuildList

If test[0].regGuild=0 Then ?"Error":sleep:end
'QSortS (test,0,test[0].regGuild-1)

Dim WhiteCol as String
Dim GreenCol as String

Dim WhiteClose as String
Dim GreenClose as String

Dim FCol     as String
Dim FClose   as String

WhiteCol="
<font color="+chr(34)+"#FFFFFF"+chr(34)+">"
GreenCol="<a href="+chr(34)+"http://www.twostepsfromhell.de.vu"+chr(34)+"><font color="+chr(34)+"#00FF00"+chr(34)+">"
WhiteClose="</font>"
GreenClose="
</font></a>"

Open "
GuildRanksAuzura.html" for Output as #76


Print #76,"
<html>"

Print #76,"
<html><body bgcolor="+chr(34)+"#000000"+chr(34)+">"
Print #76,"<div align="+chr(34)+"center"+chr(34)+"><font color="+chr(34)+"#FFFF00"+chr(34)+"><Strong>Auzura-EU Guild Ranks</strong></font><BR>"


Print #76,"
<table cellpadding="+chr(34)+"0"+chr(34)+" cellspacing="+chr(34)+"0"+chr(34)+" border="+chr(34)+"0"+chr(34)+" width="+chr(34)+"90%"+chr(34)+">"
Print #76,"<tbody><tr>"
Print #76,"
<td><strong>"+"<font color="+chr(34)+"#FFFF00"+chr(34)+">"+"Rank"+"</font>"+"</strong></td>"
Print #76,"
<td><strong>"+"<font color="+chr(34)+"#FFFF00"+chr(34)+">"+"Guild"+"</font>"+"</strong></td>"
Print #76,"
<td><strong>"+"<font color="+chr(34)+"#FFFF00"+chr(34)+">"+"Average Level"+"</font>"+"</strong></td>"
Print #76,"
<td><strong>"+"<font color="+chr(34)+"#FFFF00"+chr(34)+">"+"Points"+"</font>"+"</strong></td>"
Print #76,"
</tr></tbody>"





for l as integer=0 to test[0].regGuild-1
    FCol=WhiteCol:FClose=WhiteClose
    If *test[l].GuildName="
TwoStepsFromHell" Then FCol=GreenCol:FClose=GreenClose
    Print #76,"
<tbody><tr>"
    Print #76,"
<td>"+WhiteCol+Str(l+1)+WhiteClose+"</td>"
    Print #76,"
<td><strong>"+FCol+*test[l].GuildName+FClose+"</strong></td>"
    Print #76,"
<td>"+WhiteCol+Str(test[l].AvLevel)+WhiteClose+"</td>"
    Print #76,"
<td>"+WhiteCol+Str(test[l].GuildALevel)+WhiteClose+"</td>"
next l

Print #76,"
</Table>"
Print #76,"
</div>"
Print #76,WhiteCol+"
Updated: "+Date+WhiteClose+"<body></html>"
Print #76,"
</html>"
Close #76

?"
Ready"


sleep