Cheat prevetion for Ubytes

Source-code only - please, don't post questions here.
mrminecrafttnt
Posts: 57
Joined: Feb 11, 2013 12:23

Cheat prevetion for Ubytes

Postby mrminecrafttnt » Aug 02, 2018 16:18

Code: Select all

type memorycell
    as ubyte cell : 1
    as ubyte paritycell : 1
    as ubyte read_write_state : 1
    as ubyte protected_mode : 1
    declare function rw_cell (value as ubyte = 0) as ubyte
    declare sub lock_cell
    declare sub unlock_cell
    declare sub write_mode
    declare sub read_mode
end type

function memorycell.rw_cell (value as ubyte = 0) as ubyte
   ' print "RW CELL"
    select case read_write_state
    case 0
        if paritycell <> cell then return cell
    case 1
        if protected_mode = 0 then
            cell = value
            paritycell = not value
        end if
    end select
end function

sub memorycell.lock_cell
   ' PRINT "LOCKCELL"
    protected_mode = 1
end sub

sub memorycell.unlock_cell
   ' PRINT "UNLOCKCELL"
    protected_mode = 0
end sub

sub memorycell.write_mode
   ' PRINT "WRITEMODE"
    read_write_state = 1
end sub

sub memorycell.read_mode
   ' PRINT "READMODE"
    read_write_state = 0
end sub

type mcell_ubyte
    dim as memorycell mcell(8)
    declare sub convert_ubyte_to_celldata(value as ubyte)
    declare function convert_celldata_to_ubyte as ubyte
end type

sub mcell_ubyte.convert_ubyte_to_celldata(value as ubyte)
    'PRINT "CONVERTING TO CELLDATA"
    for i as integer = 0 to 7
        mcell(i).unlock_cell
        mcell(i).write_mode
        mcell(i).rw_cell bit(value,i)
        mcell(i).read_mode
        mcell(i).lock_cell
    next
end sub

function mcell_ubyte.convert_celldata_to_ubyte as ubyte
    'PRINT "CONVERTING TO UBYTE"
    dim as ubyte buffer
    for i as integer = 0 to 7
        if mcell(i).rw_cell = 1 then
            buffer = bitset(buffer,i)
        else
            buffer = bitreset(buffer,i)
        end if
    next
    return buffer
end function


'EXAMPLE STARTS HERE
dim as mcell_ubyte health
health.convert_ubyte_to_celldata 100
locate ,,0
do
    locate 1
    print "INCRASE/DECRASE HEALTH WITH +/-"
    SELECT CASE INKEY
    CASE "+"
        health.convert_ubyte_to_celldata health.convert_celldata_to_ubyte + 1
    case "-"
        health.convert_ubyte_to_celldata health.convert_celldata_to_ubyte - 1
       
    case chr(27)
        exit do
    end select
    print "YOUR HEALTH :";health.convert_celldata_to_ubyte; " "
loop
deltarho[1859]
Posts: 1272
Joined: Jan 02, 2017 0:34
Location: UK

Re: Cheat prevetion for Ubytes

Postby deltarho[1859] » Aug 02, 2018 23:04

@mrminecrafttnt

If I had my way I would delete your post and send you a message advising that this is a peer support forum and not a source code repository. I would then say that if any code was posted again without any explanation then it also would be deleted only no message would be sent on that occasion.
Pritchard
Posts: 5442
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: Cheat prevetion for Ubytes

Postby Pritchard » Aug 03, 2018 0:06

deltarho[1859] wrote:@mrminecrafttnt

If I had my way I would delete your post and send you a message advising that this is a peer support forum and not a source code repository. I would then say that if any code was posted again without any explanation then it also would be deleted only no message would be sent on that occasion.


There are better ways to handle this than deleting a thread. We're also in the Tips and Tricks sub-forum. You could also just ask mrminecreattnt to provide a description. I don't think we can afford to be rude to contributors at this point.

@mrminecrafttnt So you're essentially just NOT'ing values?
deltarho[1859]
Posts: 1272
Joined: Jan 02, 2017 0:34
Location: UK

Re: Cheat prevetion for Ubytes

Postby deltarho[1859] » Aug 03, 2018 1:51

Pritchard wrote:I don't think we can afford to be rude to contributors at this point.

I would normally favour a diplomatic approach but sometimes a short, sharp shock is the better tack.
Tourist Trap
Posts: 2381
Joined: Jun 02, 2015 16:24

Re: Cheat prevetion for Ubytes

Postby Tourist Trap » Aug 03, 2018 5:27

As far as I understand it, it's about locking down some of the bytes of a given buffer made with elementary bytes, some free to change, and others not.

But I don't think this is a funny implementation, this uses a user defined datatype, so outside of this very restrictive context your buffer is not really secured. I'm not sure, but more fun would be maybe to use constants and static storage, known by the compiler and the program point of view for being specific special areas for storage and theoretically protected against change. But again, not sure that it would be really effective. It would depend on the way the programer decides or not to comply with the restrictions and not starts hacking every single bytes :)

Maybe also this is totally another thing here, and I just miss the point of course.
Pritchard
Posts: 5442
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: Cheat prevetion for Ubytes

Postby Pritchard » Aug 10, 2018 2:56

deltarho[1859] wrote:
Pritchard wrote:I don't think we can afford to be rude to contributors at this point.

I would normally favour a diplomatic approach but sometimes a short, sharp shock is the better tack.

Okay, so since you like a sharp shock, how about this? If I was a mod, comments that don't actually contribute toward threads and are aggressive toward users like yours would result in immediate deletion and a temporary account ban.
deltarho[1859]
Posts: 1272
Joined: Jan 02, 2017 0:34
Location: UK

Re: Cheat prevetion for Ubytes

Postby deltarho[1859] » Aug 10, 2018 5:34

@Pritchard

That would send a message that the style of the opening post was perfectly acceptable.

It is worth noting that nobody else has 'had a go' at me suggesting a silent agreement with what I wrote. If you have seen any of my posts over the last 18 months then you will know that it is not my usual style of communication.
MrSwiss
Posts: 2679
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Cheat prevetion for Ubytes

Postby MrSwiss » Aug 10, 2018 15:36

deltarho[1859] wrote:That would send a message that the style of the opening post was perfectly acceptable.
Yes, fully agree ... (that message is simply: unacceptable!)
For a change, I'm in complete agreement, with deltarho[1859].

OP is known, to post such nonsense (related to: tips and tricks), without ever
stating a reason, giving an explanation e.t.c.
Nobody would mind, if this sort of thing was posted in "Beginners" but, "Tips
and Tricks" is definitely NOT, the right place ...
Pritchard
Posts: 5442
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: Cheat prevetion for Ubytes

Postby Pritchard » Aug 11, 2018 2:51

deltarho[1859] wrote:@Pritchard

That would send a message that the style of the opening post was perfectly acceptable.

I'm not saying anything about the opening post. Just your own behaviors.

It is worth noting that nobody else has 'had a go' at me suggesting a silent agreement with what I wrote.
This forum has like 5 active users lol.

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest