import protobuf.type.int32 namespace protobuf.type; class sint32{ ctor(...) { this = ..protobuf.type.int32(...) this.wiredType = ..protobuf.message.wiredTypeVarint; var base = { deserialize = this.deserialize; serialize = this.serialize; } } deserialize = function () { base.deserialize(); var saved = this.value; this.value = ..math.round( this.value / 2 ); if ( saved % 2 == 1) this.value = - this.value ; } serialize = function ( rec = -1 ) { var save = this.value; if (this.value < 0) { this.value = ..math.abs(this.value)*2-1; } else { this.value = this.value*2; } var str = base.serialize(rec); this.value = save; return str; } }